package org.bet.domain;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.map.ListOrderedMap;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

@Document
public class BioFeatureSet extends AbstractSyndicatedData {

	private static final long serialVersionUID = 7134761884180023933L;
	
	public static enum FeatureType{
		gene,
		mRNA, 
		CDS, 
		exon, 
		five_prime_UTR, 
		three_prime_UTR,
		enhancer,
		promoter,
		chromatin_regulatory_site
	};
	
	@Indexed
	private FeatureType type;
	
	@DBRef
	private Genome genome;
	
	@DBRef
	private Map<String, BioFeatureEntry> entryMap = new ListOrderedMap();
	
	@Indexed
	private String cellLine;
	
	public BioFeatureSet(String name, Syndicator syndicator) {
		super(name, syndicator);
	}

	public FeatureType getType() {
		return type;
	}

	public void setType(FeatureType type) {
		this.type = type;
	}


	public Genome getGenome() {
		return genome;
	}

	public void setGenome(Genome genome) {
		this.genome = genome;
	}

	public void addEntry(BioFeatureEntry entry){
		entryMap.put(entry.getId(), entry);
	}
	
	public void removeEntry(String id){
		entryMap.remove(id);
	}
	
	public BioFeatureEntry getEntryById(String id){
		return (BioFeatureEntry) entryMap.get(id);
	}
	
	public Map<String, BioFeatureEntry> getEntryMap() {
		return entryMap;
	}

	public List<BioFeatureEntry> getEntries(){
		return (List<BioFeatureEntry>) ((ListOrderedMap) entryMap).values();
	}

	public String getCellLine() {
		return cellLine;
	}

	public void setCellLine(String cellLine) {
		this.cellLine = cellLine;
	}

}
